package com.ibeeking.found.content.c.rest.controller.v1;

import com.ibeeking.found.common.enums.PublishStatusEnum;
import com.ibeeking.found.content.c.rest.service.IBroadcastCommentService;
import com.ibeeking.found.content.c.rest.service.IBroadcastGoodsService;
import com.ibeeking.found.content.c.rest.service.IBroadcastCouponService;
import com.ibeeking.found.content.c.rest.service.IBroadcastGroupService;
import com.ibeeking.found.content.c.rest.service.IBroadcastService;
import com.ibeeking.found.content.service.common.param.BroadcastCommentParam;
import com.ibeeking.found.content.service.common.query.*;
import com.ibeeking.found.content.service.common.vo.*;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName BroadcastController控制器
 * @Description
 * @Author ibeeking
 * @Date 2022-02-18 14:11
 **/
@RestController
@RequestMapping("/c/broadcast/v1")
public class BroadcastController {

    @Resource
    private IBroadcastService broadcastServiceImpl;
    @Resource
    private IBroadcastGoodsService broadcastGoodsServiceImpl;
    @Resource
    private IBroadcastCouponService broadcastCouponServiceImpl;
    @Resource
    private IBroadcastGroupService broadcastGroupServiceImpl;
    @Resource
    private IBroadcastCommentService broadcastCommentServiceImpl;

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间列表")
    @PostMapping(value = "/list")
    public List<BroadcastVO> list(@RequestBody BroadcastQuery broadcastQuery) {
        return broadcastServiceImpl.list(broadcastQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间上架商品列表")
    @PostMapping(value = "/listOnsaledGoods")
    public List<BroadcastGoodsVO> listOnsaledGoods(@RequestBody BroadcastQuery broadcastQuery) {
        return broadcastServiceImpl.listOnsaledGoods(broadcastQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间上架优惠券列表")
    @PostMapping(value = "/listOnsaledCoupon")
    public List<BroadcastCouponVO> listOnsaledCoupon(@RequestBody BroadcastQuery broadcastQuery) {
        return broadcastServiceImpl.listOnsaledCoupon(broadcastQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间分页列表")
    @PostMapping(value = "/pageList")
    public Page<BroadcastVO> pageList(@RequestBody BroadcastPageQuery broadcastPageQuery) {
        return broadcastServiceImpl.pageList(broadcastPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间查看")
    @GetMapping(value = "/view/{id}")
    public BroadcastVO view(@PathVariable("id") Long id) {
        return broadcastServiceImpl.view(id);
    }

    /**
     * ------------直播间商品
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间商品列表")
    @PostMapping(value = "/goods/list")
    public List<BroadcastGoodsVO> goodsList(@RequestBody BroadcastGoodsQuery broadcastGoodsQuery) {
        return broadcastGoodsServiceImpl.list(broadcastGoodsQuery);
    }
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间商品查看")
    @GetMapping(value = "/goods/view/{id}")
    public BroadcastGoodsVO goodsView(@PathVariable("id") Long id) {
        return broadcastGoodsServiceImpl.view(id);
    }

    /**
     * ------------直播间优惠券
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间优惠券列表")
    @PostMapping(value = "/coupon/list")
    public List<BroadcastCouponVO> couponList(@RequestBody BroadcastCouponQuery broadcastCouponQuery) {
        return broadcastCouponServiceImpl.list(broadcastCouponQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间优惠券查看")
    @GetMapping(value = "/coupon/view/{id}")
    public BroadcastCouponVO couponView(@PathVariable("id") Long id) {
        return broadcastCouponServiceImpl.view(id);
    }

    /**
     * ------------直播间分组
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间分组列表")
    @PostMapping(value = "/group/list")
    public List<BroadcastGroupVO> groupList(@RequestBody BroadcastGroupQuery broadcastGroupQuery) {
        return broadcastGroupServiceImpl.list(broadcastGroupQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间分组分页列表")
    @PostMapping(value = "/group/pageList")
    public Page<BroadcastGroupVO> groupPageList(@RequestBody BroadcastGroupPageQuery broadcastGroupPageQuery) {
        return broadcastGroupServiceImpl.pageList(broadcastGroupPageQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "直播间分组查看")
    @GetMapping(value = "/group/view/{id}")
    public BroadcastGroupVO groupView(@PathVariable("id") Long id) {
        return broadcastGroupServiceImpl.view(id);
    }

    /**
     * 评论管理
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "评论分页列表")
    @PostMapping(value = "/comment/pageList")
    public Page<BroadcastCommentVO> commentPageList(@RequestBody BroadcastCommentPageQuery broadcastCommentPageQuery) {
        broadcastCommentPageQuery.setPublishStatus(PublishStatusEnum.ENABLE.getValue());
        return broadcastCommentServiceImpl.pageList(broadcastCommentPageQuery);
    }

    /**
     * 评论管理
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "评论保存")
    @PostMapping(value = "/comment/save")
    public Boolean commentSave(@RequestBody BroadcastCommentParam broadcastCommentParam) {
        return broadcastCommentServiceImpl.save(broadcastCommentParam);
    }

}
